package com.blackshadowgame.rps;

import com.blackshadowgame.utils.LogUtil;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.rpc.IRemoteObject;

public class GameHostService extends Ability {
    private static final String TAG = GameHostService.class.getSimpleName();

    private GameServiceObject gameServiceObject = new GameServiceObject("GameHostService");

    @Override
    public void onStart(Intent intent) {
        LogUtil.info(TAG, "游戏服务: 启动");
        super.onStart(intent);
    }

    @Override
    public void onBackground() {
        super.onBackground();
        LogUtil.info(TAG, "游戏服务: onBackground");
    }

    @Override
    public void onStop() {
        super.onStop();
        LogUtil.info(TAG, "游戏服务: onStop");
    }

    @Override
    public void onCommand(Intent intent, boolean restart, int startId) {
        LogUtil.info(TAG, "游戏服务: onCommand");
    }

    @Override
    public IRemoteObject onConnect(Intent intent) {
        // 有连接请求
        LogUtil.info(TAG, "游戏服务: onConnect");

        return gameServiceObject.asObject();
    }

    @Override
    public void onDisconnect(Intent intent) {
        LogUtil.info(TAG, "游戏服务: onDisconnect");
    }
}